<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><link href="__TMPL__Static/Css/style.css" rel="stylesheet" /><script type="text/javascript" src="__TMPL__Static/Js/jquery.js"></script><script type="text/javascript" src="__TMPL__Static/Js/base.js"></script><script type="text/javascript" src="__TMPL__Static/Js/json.js"></script><script type="text/javascript" src="__TMPL__Static/Js/jquery.pngFix.js"></script><link href="__TMPL__Static/Css/tooltip.css" rel="stylesheet" /><script type="text/javascript" src="__TMPL__Static/Js/jquery.tooltip.js"></script><script type="text/javascript"><!--
//指定当前组模块URL地址 
var URL = '__URL__';
var ROOT_PATH = '__ROOT__';
var APP	 =	 '__APP__';
var STATIC = '__TMPL__Static';
var VAR_MODULE = '<?php echo c('VAR_MODULE');?>';
var VAR_ACTION = '<?php echo c('VAR_ACTION');?>';
var CURR_MODULE = '<?php echo ($module_name); ?>';
var CURR_ACTION = '<?php echo ($action_name); ?>';

//定义JS中使用的语言变量
var CONFIRM_DELETE = '<?php echo (L("CONFIRM_DELETE")); ?>';
var AJAX_LOADING = '<?php echo (L("AJAX_LOADING")); ?>';
var AJAX_ERROR = '<?php echo (L("AJAX_ERROR")); ?>';
var ALREADY_REMOVE = '<?php echo (L("ALREADY_REMOVE")); ?>';
var SEARCH_LOADING = '<?php echo (L("SEARCH_LOADING")); ?>';
var CLICK_EDIT_CONTENT = '<?php echo (L("CLICK_EDIT_CONTENT")); ?>';
//--></script></head><body><div class="fanwe-body"><div class="fb-title"><div><p><span><?php echo ($ur_href); ?></span></p></div></div><div class="fb-body"><table class="body-table" cellpadding="0" cellspacing="1" border="0"><tr><td class="body-table-td"><div class="body-table-div"><script type="text/javascript" src="__TMPL__Static/Js/user.js"></script><form method='post' id="form" name="form" action="<?php echo U(MODULE_NAME.'/update');?>"><table cellpadding="4" cellspacing="0" border="0" class="table-form"><tr><th width="180">&nbsp;</th><td><p>					采集过程会执行比较长的时间，需要设置PHP运行时间，请关闭 PHP 安全模式；<br/>					采集时如果已有该商品的分享，则会跳过该商品；<br/>					为避免后台采集冲突或设置冲突，请只设置一个管理员可以进行后台采集和采集设置；<br/>					当更新设置后或后台采集时，为避免采集冲突，将锁定采集，自动采集将停止；
					<?php if($is_auto_collect): ?><br/><span style="color:#00f;">当前正在进行自动采集</span>，采集开始时间为 <?php echo toDate($auto_collect['time']);?>。
					<br/><span style="color:#f00;">如果要手动清除锁定</span>，请点击 【<a href="<?php echo U('TaobaoCollect/clearautolock');?>">清除锁定</a>】 ，清除锁定后，如果要进行自动采集，请点击保存 以生成自动采集定进任务。<?php endif; if($is_collect_lock): ?><br/><span style="color:#f00;">当前自动采集已锁定</span>，请点击 【<a href="<?php echo U('TaobaoCollect/clearlock');?>">清除锁定</a>】<?php endif; ?></p></td></tr><tr><th>自动采集</th><td><label><input type="checkbox" name="is_auto_collect" value="1" id="isAutoCollect" <?php if($vo['is_auto_collect'] == 1): ?>checked="checked"<?php endif; ?>/></label><span>&nbsp;(当有用户访问网站时，自动检测是否已执行采集操作)</span></td></tr><tr class="autocCollectTr" <?php if($vo['is_auto_collect'] == 0): ?>style="display:none;"<?php endif; ?>><th>采集间隔时间</th><td><input type="text" name="collect_time" value="<?php echo ($vo["collect_time"]); ?>" size="2" class="textinput" />&nbsp;小时(采集间隔时间不能小于1)
			</td></tr><tr><th>数据排序</th><td><select name="sort_order"><option value="price_desc" <?php if($vo['sort_order'] == 'price_desc'): ?>selected="selected"<?php endif; ?>>价格从高到低</option><option value="price_asc" <?php if($vo['sort_order'] == 'price_asc'): ?>selected="selected"<?php endif; ?>>价格从低到高</option><option value="credit_desc" <?php if($vo['sort_order'] == 'credit_desc'): ?>selected="selected"<?php endif; ?>>信用等级从高到低</option><option value="commissionRate_desc" <?php if($vo['sort_order'] == 'commissionRate_desc'): ?>selected="selected"<?php endif; ?>>佣金比率从高到低</option><option value="commissionRate_asc" <?php if($vo['sort_order'] == 'commissionRate_asc'): ?>selected="selected"<?php endif; ?>>佣金比率从低到高</option><option value="commissionNum_desc" <?php if($vo['sort_order'] == 'commissionNum_desc'): ?>selected="selected"<?php endif; ?>>成交量从高到低</option><option value="commissionNum_asc" <?php if($vo['sort_order'] == 'commissionNum_asc'): ?>selected="selected"<?php endif; ?>>成交量从低到高</option><option value="commissionVolume_desc" <?php if($vo['sort_order'] == 'commissionVolume_desc'): ?>selected="selected"<?php endif; ?>>总支出佣金从高到低</option><option value="commissionVolume_asc" <?php if($vo['sort_order'] == 'commissionVolume_asc'): ?>selected="selected"<?php endif; ?>>总支出佣金从低到高</option><option value="delistTime_desc" <?php if($vo['sort_order'] == 'delistTime_desc'): ?>selected="selected"<?php endif; ?>>商品下架时间从高到低</option><option value="delistTime_asc" <?php if($vo['sort_order'] == 'delistTime_asc'): ?>selected="selected"<?php endif; ?>>商品下架时间从低到高</option></select></td></tr><tr><th>分类采集页数</th><td><input type="text" value="<?php echo ($vo["page_num"]); ?>" class="textinput" name="page_num" size="3"><span>&nbsp;(所选分类采集的页数，页数为 1 到 10)</span></td></tr><tr><th>分享会员</th><td><p>					可设置多个会员，写入分享数据表时，根据设置随机分配会员；<br/>					如果只选择会员组，请保证会员组下有正常状态下的会员；<br/></p></td></tr><tr><th>&nbsp;</th><td><table class="fl" cellpadding="0" cellspacing="0"><tr><td style="border:none; padding:0; text-align:left;" colspan="2"><span>会员名&nbsp;</span><input type="text" class="textinput" size="8" id="userName" />&nbsp;
							<input class="submit_btn" type="button" value="<?php echo (L("SEARCH")); ?>" onclick="searchUser('#userSelect','#userName');" /></td><td style="border:none; padding:0;text-align:center;"><p>所选会员</p></td><td width="30" rowspan="2" style="border:none; padding:0;">&nbsp;</td><td style="border:none; padding:0;text-align:center;"><p>设置会员组</p></td></tr><tr><td style="border:none;"><select multiple="multiple" id="userSelect" style="width:160px;" size="12"></select></td><td width="60" style="border:none;"><input type="button" value=">>" name="add" id="addUserBtn" class="formbutton" /><div class="blank9"></div><input type="button" value="<<" name="remove" id="removeUserBtn" class="formbutton" /></td><td style="border:none;"><select multiple="multiple" id="userIdsSelect" style="width:160px;" size="12"><?php if(is_array($user_list)): foreach($user_list as $key=>$user): ?><option value="<?php echo ($user["uid"]); ?>"><?php echo ($user["user_name"]); ?></option><?php endforeach; endif; ?></select><input type="hidden" name="user_ids" value="<?php echo ($vo["user_ids"]); ?>" id="userIds" /></td><td style="border:none;"><select name="user_gid" id="userGidSelect" style="width:260px;" size="12"><option value="0">不设置</option><?php if(is_array($group_list)): foreach($group_list as $gid=>$gname): ?><option value="<?php echo ($gid); ?>" <?php if($gid == $vo['user_gid']): ?>selected="selected"<?php endif; ?>><?php echo ($gname); ?></option><?php endforeach; endif; ?></select></td></tr></table></td></tr><tr><th>采集分类</th><td><p>如果选择上级分类，将取消他所有的子级分类。如果选择子分类，将取消他所属的上级分类。双击设置采集分类</p></td></tr><tr><th style="text-align:center; vertical-align:top;padding-left:0;padding-right:0;"><p style="padding:3px 0 10px 0">已设置的分类(双击删除)</p><select multiple="multiple" id="cateSelect" style="width:170px;height:400px;" size="12"><?php if(is_array($cate_slist)): foreach($cate_slist as $key=>$cate): ?><option value="<?php echo ($cate["id"]); ?>" parentID="<?php echo ($cate["pid"]); ?>"><?php echo ($cate["name"]); ?></option><?php endforeach; endif; ?></select><input type="hidden" name="cate_ids" value="<?php echo ($vo["cate_ids"]); ?>" id="cateIds" /></th><td><p style="padding:0 0 7px 20px;">分类列表(双击选定)</p><div style="width:100%; overflow-x:auto; text-align:left;"><table cellpadding="0" cellspacing="0" border="0" class="table-normal" align="left"><tr id="cateBox"><td><select multiple="multiple" class="cateSelect" style="height:400px;"><?php if(is_array($cate_list)): foreach($cate_list as $key=>$cate): ?><option value="<?php echo ($cate['id']); ?>"><?php echo ($cate['name']); ?></option><?php endforeach; endif; ?></select></td></tr></table></div></td></tr><tr><th>采集关键字</th><td><p>只采集商品标题中包含有关键字的商品(为空则采集分类的所有商品)，请在采集分类设置完成后，再为设置分类对应的关键字</p></td></tr><tr><th>&nbsp;</th><td id="cateKeywords"><table align="left" cellpadding="0" cellspacing="0" border="0"><tbody><?php if(is_array($cate_keywords)): foreach($cate_keywords as $key=>$cate_keyword): ?><tr><th nowrap="nowrap" style="border:none; padding:2px 0;"><?php echo ($cate_keyword["name"]); ?>：</th><td style="border:none; padding:2px 0;"><input type="text" name="keywords[<?php echo ($cate_keyword["id"]); ?>]" class="textinput keyinput_<?php echo ($cate_keyword["id"]); ?>" value="<?php echo ($cate_keyword["keywords"]); ?>" /></td></tr><?php endforeach; endif; ?></tbody></table></td></tr><tr class="act"><th>&nbsp;</th><td><input type="submit" class="submit_btn" value="<?php echo (L("SAVE")); ?>" />&nbsp;&nbsp;
				<input type="submit" id="saveCollect" class="submit_btn" value="<?php echo (L("COLLECT")); ?>" />&nbsp;&nbsp;
				<input type="reset" class="reset_btn" value="<?php echo (L("RESET")); ?>" /><input type="hidden" name="is_collect" value="0" id="isCollect" /></td></tr></table></form><script type="text/javascript">var EMPTY_USER = "<?php echo getLang('EMPTY_USER','User');?>";
jQuery(function($){
	$("#saveCollect").click(function(){
		$("#isCollect").val(1);
	});
	
	$("#form").submit(function(){
		var ids = new Array();
		var opts,i;
		
		opts = $("#userIdsSelect option");
		ids = new Array();
		for(i=0;i<opts.length;i++)
		{
			ids.push($(opts[i]).attr("value"));
		}
		
		if(ids.length == 0 && $("#userGidSelect").val() == 0)
		{
			alert("请选择至少一个会员，或者会员组");
			return false;	
		}
		
		$("#userIds").val(ids.join(","));
		
		opts = $("#cateSelect option");
		ids = new Array();
		for(i=0;i<opts.length;i++)
		{
			ids.push($(opts[i]).attr("value"));
		}
		if(ids.length == 0)
		{
			alert("请选择至少一个采集分类");
			return false;	
		}
		$("#cateIds").val(ids.join(","));
	});
	
	$("#userSelect").bind("dblclick",function(){
		addUserOption();
	});
	$("#addUserBtn").bind("click",function(){
		addUserOption();
	});
	
	$("#userIdsSelect").bind("dblclick",function(){
		removeUserOption();
	});
	
	$("#removeUserBtn").bind("click",function(){
		removeUserOption();
	});
	
	$("#isAutoCollect").change(function(){
		if(this.checked)
			$(".autocCollectTr").show();
		else
			$(".autocCollectTr").hide();
	});
	
	$(".cateSelect").live('change',function(){
		var obj = this;
		var query = new Object();
		query.id = this.value;
		query.type = 'taobao';
		
		if(query.id == '')
			return;
					
		$.ajax({
			url: APP + '?' + VAR_MODULE + '=GoodsCatesGl&' + VAR_ACTION + '=getSelect',
			type:"POST",
			async:false,
			cache: false,
			data:query,
			dataType:"text",
			success: function(result){
				$(obj).parent().nextAll().remove();
				var html = '<td>'+ result +'</td>';
				$("#cateBox").append(html);
			}
		});
	});
	
	$(".cateSelect").live('dblclick',function(){
		var pids = new Array();
		var val = this.value;
		$("#cateSelect option").each(function(){
			if((',' + $(this).attr('parentIDs') + ',').indexOf(',' + val + ',') > -1)
				$(this).remove();
		});
		
		$(this).parent().nextAll().each(function(){
			$("select option",this).each(function(){
				$("#cateSelect option[value='"+ $(this).val() +"']").remove();
			});
		});
		
		$(this).parent().prevAll().each(function(){
			$("select",this).each(function(){
				pids.unshift($(this).val());
				$("#cateSelect option[value='"+ $(this).val() +"']").remove();
			});
		});
		
		updateCateSelect(val,$('option:selected',this).text(),pids.join(","));
	});
	
	$("#cateSelect").bind("dblclick",function(){
		$("#cateSelect option:selected").remove();
		updateCateKeywords();
	});
});

function addUserOption()
{
	var select_option = $("#userSelect option:selected");
	var user_option = $("#userIdsSelect option");
	var obj = new Array();
	var i,j;
	
	for(i=0;i<select_option.length;i++)
	{
		is_add = true;
		for (j = 0; j < user_option.length; j++) 
		{
			if ($(select_option[i]).attr("value") == $(user_option[j]).attr("value")) 
			{
				is_add = false;
				break;
			}
		}
		if(is_add)
		{
			obj.push(select_option[i]);
		}
	}
	var clone = $(obj).clone();
	$("#userIdsSelect").append(clone);
}

function removeUserOption()
{
	$("#userIdsSelect option:selected").remove();	
}

function updateCateSelect(id,name,pids)
{
	var is_add = true;
	var coptions = $("#cateSelect option");
	for (i = 0; i < coptions.length; i++) 
	{
		if ($(coptions[i]).attr("value") == id) 
		{
			is_add = false;
			break;
		}
	}
	
	if(is_add)
	{
		var html = '<option parentIDs="'+ pids +'" value="'+ id +'">'+name+'</option>';
		$("#cateSelect").prepend(html);
		updateCateKeywords();
	}
}

function updateCateKeywords()
{
	var html = '';
	var cates = new Array();
	var cate;
	$("#cateSelect option").each(function(){
		cate = new Object();
		cate.id = this.value;
		cate.name = $(this).text();
		if($("#cateKeywords .keyinput_" + this.value).length > 0)
			cate.keywords = $("#cateKeywords .keyinput_" + this.value).val();
		else
			cate.keywords = '';
		cates.push(cate);
	});
	$("#cateKeywords").html('');
	
	for(var i = 0;i < cates.length;i++)
	{
		cate = cates[i];
		html += '<tr><th nowrap="nowrap" style="border:none; padding:2px 0;">'+ cate.name +'：</th><td style="border:none; padding:2px 0;"><input type="text" name="keywords['+ cate.id +']" class="textinput keyinput_'+ cate.id +'" value="'+ cate.keywords +'" /></td></tr>';
	}
	$("#cateKeywords").html('<table align="left" cellpadding="0" cellspacing="0" border="0"><tbody>' + html + '</tbody></table>');
}
</script></div></td></tr></table></div></div><div class="ajax-loading"></div></body><script type="text/javascript">jQuery(function($){
	updateBodyDivHeight();
	$(window).resize(function(){
		updateBodyDivHeight();
	});
	$('.imgTooltip').poshytip();
});

function updateBodyDivHeight()
{
	jQuery(".body-table-div").height(jQuery(".fanwe-body").height() - 36);
	if(jQuery(".body-table-div").get(0).scrollHeight > jQuery(".body-table-div").height())
	{
		var width = jQuery(".body-table-div").width() - 16;
		jQuery(".body-table-div > *").each(function(){
			if(!$(this).hasClass('ajax-loading'))
			{
				$(this).width(width)	
			}
		});
	}
}
</script></html>